﻿#ifndef DEVICECONFIGTAB_H
#define DEVICECONFIGTAB_H

#include <QDockWidget>
#include "Main/datatype.h"
#include <QProgressDialog>

class ConfirmDevice;
namespace Ui {
class DeviceConfigTab;
}

class DeviceConfigTab : public QDockWidget
{
    Q_OBJECT

public:
    explicit DeviceConfigTab(QWidget *parent = nullptr);
    ~DeviceConfigTab();
    double m_TSC[4];
    QTimer* m_timer_TSC;

private:
    Ui::DeviceConfigTab *ui;
    ConfirmDevice* confirmDevice;
    QString LocalDateTime = "";
    bool m_Start_Simple = true;
    uint m_iPageQuantityTSC = 1;
    int m_iInterval;
    bool m_bIM;
    QByteArray arrLED;
    bool bOK = false;
    time_t m_iStartTime;
    int iBarVal =0;

	QVector<time_t> m_vecDateTime;
    QVector<double> m_vecH ;
    QVector<double> m_vecTemperature ;
    QProgressDialog* mProgressTSC =nullptr;


    void initDockConfig();
    void HandDeviceInfo_TSC(QByteArray, QByteArray);
    void setSampleStatusOne(bool flag);
    void setSampleStatusTwo(bool flag);
    void setSampleStatusFlagThird(bool flag);
    void setSampleStatusFlagFour(bool flag);
    void setSampleStatus(bool flag);

    void HandBattery_TSC(QByteArray data, QByteArray flag);
    void HandSampleConfig_TSC(QByteArray data, QByteArray flag);
    void HandTemperatureCoefficient_TSC(QByteArray data);
    void HandSyncTime_TSC(QByteArray data);
    void HandCoefficientTimeTSC(QByteArray data, QByteArray flag);
    void HandSampleAfterDataTSC(QByteArray data, QByteArray flag);
    void setProgressValue();
    void setStartSample();
    QList<QByteArray> ByteSplit(QByteArray& arrByte, const QByteArray& arrSplit);
    void saveDownFileTSC();

private slots:
    void HandleTypeTSC(Message_t);

    void on_m_Ptn_SaveCoefficient_clicked();

    void on_m_Calibration_Coefficient_clicked();

    void on_m_pushButton_StartSample_clicked();

    void on_m_pbn_Save_Config_clicked();
    void recvFlashDataFromTSC(QByteArray arrDataHex);

    void on_m_pbn_DownLoad_clicked();

    void on_m_Use_Last_Config_clicked();

    void on_m_radioButton_Hour_clicked(bool checked);

    void on_m_radioButton_Minute_clicked(bool checked);

    void on_m_radioButton_Second_clicked(bool checked);

    void on_m_Button_SyncLocalTime_clicked();

    void on_m_radio_LocalDateTime_clicked(bool checked);

public slots:
    void recvSampleEnableStatus(bool flag);
    void reciveComNameTSC(QString& portName);
signals:
    void sendVerifyCoefficient(ModetoConfig);
    void sendIsEnableRotateButton(bool);
};

#define DeviceConfigTabRelease Singleton<DeviceConfigTab>::Release()
#define DeviceConfigTabInstance Singleton<DeviceConfigTab>::GetInstance()

#endif // DEVICECONFIGTAB_H
